using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter18
{
	/// <summary>
	/// Example06: Wind in a Culvert
	/// A section of drainage culvert 1.23 m in length makes a 
	/// howling noise when the wind blows.
	/// (A) Determine the frequencies of the first three harmonics
	/// of the culvert if it is cylindrical in shape and open at
	/// both ends. Take v = 343 m/s as the speed of sound in air.
	/// f_1 = 139 Hz
	/// f_2 = 278 Hz
	/// f_3 = 417 Hz
	/// (B) What are the three lowest natural frequencies of the 
	/// culvert if it is blocked at one end?
	/// f_1 = 69.7 Hz
	/// f_3 = 209 Hz
	/// f_5 = 349 Hz
	/// (C) For the culvert open at both ends, how many of the 
	/// harmonics present fall within the normal human hearing
	/// range (20 to 20000 Hz)?
	/// n = 143
	/// </summary>
	public class Example06
	{
		public Example06()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			double v = 343.0;
			double L = 1.23;
			//(A)
			// v = lambda_n*f_n
			// lambda_n = 2*L/n
			// f_n = v/2/L*n
			result+=Convert.ToString(v/2/L*1)+"\r\n";      
			result+=Convert.ToString(v/2/L*2)+"\r\n";      
			result+=Convert.ToString(v/2/L*3)+"\r\n";
			//(B)
			// v = lambda_n*f_n
			// lambda_n = 4*L, 4*L/3, 4*L/5
			// f_n = v/4/L*n
			result+=Convert.ToString(v/4/L*1)+"\r\n";      
			result+=Convert.ToString(v/4/L*3)+"\r\n";      
			result+=Convert.ToString(v/4/L*5)+"\r\n";
			//(C)
			double number = (20000-20)/(v/2/L*1);
			result+=Convert.ToString(number)+"\r\n";
		}
	}
}
